using System;
using System.Collections;

using LocalBoard.Domain;
using LocalBoard.Persistence;

namespace LocalBoard.Controller
{
	/// <summary>
	/// Summary description for ClubBoardController.
	/// </summary>
	public class ClubBoardController : BoardController
	{
		private IMessageAccessor _messageAccessor;

		public ClubBoardController(ClubController clubController, int currentPageNo, IAccessorFactory accessorFactory) : base(0, clubController, currentPageNo, accessorFactory)
		{
			_messageAccessor = AccessorFactory.GetMessageAccessor();
		}

		public override int TotalRootMessageCount
		{
			get {return _messageAccessor.GetTotalRootMessageCountByClubId(ClubController.ClubId);}
		}

		public override ArrayList GetMessageListForCurrentPage()
		{
			return _messageAccessor.GetMessageListByClubId(ClubController.ClubId, MessageNumberPerPage, CurrentPageNo);
		}

		public override BoardSecurity GetBoardSecurity()
		{
			return new ClubBoardSecurity(ClubController);
		}

		public override int PostPollMessage(string subject, string body, Profile user, int replyToMessageId)
		{
			throw new NotSupportedException("This method is not supported at the ClubBoardController type. Try BoardController type instead if you know the board id.");
		}

		public override int PostMessage(Message message)
		{
			throw new NotSupportedException("This method is not supported at the ClubBoardController type. Try BoardController type instead if you know the board id.");
		}

		private ArrayList GetBoardList()
		{
			ArrayList boardList = new ArrayList();
			foreach(Board board in ClubController.GetBoardList())
			{
				boardList.Add(board);
			}
			return boardList;
		}
	}
}